package controllers.report;

import controllers.BaseController;
import controllers.auth.Secure;
import jodd.util.StringUtil;
import models.merchant.Merchant;
import order.Order;
import org.apache.commons.lang.StringUtils;
import play.mvc.Controller;
import play.mvc.With;
import utils.DateUtil;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 支付类型
 * Created by hanbin on 17/5/8.
 */
@With(BaseController.class)
public class PayTypeCtrl extends Controller {

    public static void index(String startDate, String endDate){

        startDate = StringUtils.isBlank(startDate) ? DateUtil.dateToString(DateUtil.getBeforeDate(new Date() , 7) , "MM/dd/yyyy")  : startDate;
        endDate = StringUtil.isBlank(endDate) ? DateUtil.dateToString(new Date() , "MM/dd/yyyy") : endDate;
        Merchant merchant = Secure.getLoginUser().merchant;

        List<Map<String,Object>> orderList = Order.loadOrderPayType(merchant.id, startDate, endDate);

        flash.put("menuId", "19");

        render(orderList, startDate, endDate);
    }

}
